package
{
	import com.dannypatterson.remoting.FaultEvent;
	import com.dannypatterson.remoting.ResultEvent;
	import com.dannypatterson.remoting.ServiceProxy;
	
	import flash.display.Sprite;
	
	import vos.Article;
	
	public class gameSample extends Sprite
	{
		private var stockService:ServiceProxy;
		private var stock:Array;
		
		public function gameSample()
		{
			stockService = new ServiceProxy("http://localhost:8080/SharkStockServer/messagebroker/amf", "StockService");
			stockService.addEventListener(ResultEvent.RESULT, onResult, false, 0, true);
			stockService.addEventListener(FaultEvent.FAULT, onFault, false, 0, true);
			stockService.addEventListener(FaultEvent.CONNECTION_ERROR, onConnectionError, false, 0, true);
			stockService.getStock();
		}
		
		private function onConnectionError(event:FaultEvent):void {
			trace(event.fault);
		}
		
		private function onFault(event:FaultEvent):void {
			trace(event.fault);
		}
		
		private function onResult(event:ResultEvent):void {
			stock = event.result.source as Array;
			//You'll find inside stock an array of Objects with the same structure than vos.Article
			trace(stock); // <--- PUT A BREAKPOINT HERE AND WATCH this.stock VARIABLE
		}
	}
}